{template 'common/header'}
<script type="text/javascript">
$(function() {
	$('.module').delegate('.media-description-button', 'click', function(){ //控制模块详细信息
		$(this).parents('.item').find('.media-description').toggle();
		return false;
	});
});
</script>
<style type="text/css">
small a{color:#999;}
.module{padding:15px;}
.form h4{margin-bottom:0;}
</style>
{template 'extension/module-tabs'}
<div class="main">
	{if $do == 'installed'}
	<div class="form">
		<h4>已安装的模块</h4>
	</div>
	<div class="module form-horizontal">
		{loop $modules $row}
		<div class="item">
			<div class="media">
				<div class="pull-right" style="width:230px;">
					<div class="input-prepend">
					</div>
					<div class="module-set">
						{if $row['version_error']}
						版本不兼容 <a href="{php echo create_url('extension/module/convert', array('id' => strtolower($row['name'])))}" style="color:red;">转换版本</a>
						{else}
						{if !$row['issystem']}
						<a onclick="return confirm('卸载模块会删其相关数据，确定吗？'); return false;" href="{php echo create_url('extension/module/uninstall', array('id' => $row['name']))}">卸载</a>
						{/if}
						{/if}
						<span class="upgrade-label" module="{$row['name']}" version="{$row['version']}"></span>
						<a href="{php echo create_url('extension/module/permission', array('id' => $row['name']))}">访问权限</a>
						&nbsp;
					</div>
				</div>
				<img class="media-object img-rounded" src="./source/modules/{$row['name']}/icon.jpg" onerror="this.src='./resource/image/module-nopic-small.jpg'">
				<div class="media-body">
					<h4 class="media-heading">{$row['title']}<small>（标识：{$row['name']}&nbsp;&nbsp;&nbsp;作者：{$row['author']}）</small> <em class="upgrade-label-tips" module="{$row['name']}" style="color:red;display:none;">New</em></h4>
					<span>{$row['ability']}&nbsp;<a href="#" class="media-description-button">详细介绍</a></span >
				</div>
			</div>
			<div class="media-description">
				<b>功能介绍：</b>
				<span>{$row['description']}</span>
			</div>
		</div>
		{/loop}
	</div>
	<script type="text/javascript">
		$(function(){
			$.post('{php echo create_url('extension/module/check');}', {},function(dat){
				try {
					var ret = $.parseJSON(dat);
					$('.upgrade-label').each(function(){
						var n = $(this).attr('module');
						var v = $(this).attr('version');
						if(ret[n] && ret[n].version > v) {
							var tips = '';
							if(ret[n].from == 'local') {
								tips = '来自本地文件更新';
							} else {
								tips = '来自微擎云服务更新';
							}
							$(this).html('<a href="{php echo create_url('extension/module/upgrade')}' + n + '" style="color:red;" title="' + tips + '">更新</a>');
							$('.upgrade-label-tips[module=' + n + ']').show();
						}
					});
				} catch(err) {}
			});
		});
	</script>
	{/if}
	{if $do == 'prepared'}
	<div class="form">
		<h4>已购买的模块</h4>
	</div>
	<div class="module form-horizontal">
		{loop $cloudUninstallModules $row}
		<div class="item">
			<div class="media">
				<div class="pull-right" style="width:230px;">
					<div class="module-set">
						{if $row['version_error']}
						版本不兼容 <a href="{php echo create_url('extension/module/convert', array('id' => strtolower($row['name'])))}" style="color:red;">转换版本</a>
						{else}
						<a href="{php echo create_url('extension/module/install', array('id' => strtolower($row['name'])))}">安装</a>
						{/if}
						<a href="{php echo create_url('extension/module/permission', array('id' => strtolower($row['name'])))}">访问权限</a>
						&nbsp;
					</div>
				</div>
				<img class="media-object img-rounded gray" src="./source/modules/{php echo strtolower($row['name']);}/icon.jpg" onerror="this.src='./resource/image/module-nopic-small.jpg'">
				<div class="media-body">
					<h4 class="media-heading">{$row['title']}<small>（标识：{$row['name']}&nbsp;&nbsp;&nbsp;作者：{$row['author']}）</small></h4>
					<span>{$row['ability']}&nbsp;<a href="#" class="media-description-button">详细介绍</a></span >
				</div>
			</div>
			<div class="media-description">
				<b>功能介绍：</b>
				<span>
					{$row['description']}
				</span>
			</div>
		</div>
		{/loop}
	</div>
	<div class="form">
		<h4>未安装的模块(本地模块)</h4>
	</div>
	<div class="module form-horizontal">
		{loop $localUninstallModules $row}
		<div class="item">
			<div class="media">
				<div class="pull-right" style="width:230px;">
					<div class="module-set">
						{if $row['version_error']}
						版本不兼容 <a href="{php echo create_url('extension/module/convert', array('id' => strtolower($row['name'])))}" style="color:red;">转换版本</a>
						{else}
						<a href="{php echo create_url('extension/module/install', array('id' => strtolower($row['name'])))}">安装</a>
						{/if}
						<a href="{php echo create_url('extension/module/permission', array('id' => strtolower($row['name'])))}">访问权限</a>
						&nbsp;
					</div>
				</div>
				<img class="media-object img-rounded gray" src="./source/modules/{php echo strtolower($row['name']);}/icon.jpg" onerror="this.src='./resource/image/module-nopic-small.jpg'">
				<div class="media-body">
					<h4 class="media-heading">{$row['title']}<small>（标识：{$row['name']}&nbsp;&nbsp;&nbsp;作者：{$row['author']}）</small></h4>
					<span>{$row['ability']}&nbsp;<a href="#" class="media-description-button">详细介绍</a></span >
				</div>
			</div>
			<div class="media-description">
				<b>功能介绍：</b>
				<span>
					{$row['description']}
				</span>
			</div>
		</div>
		{/loop}
	</div>
	{/if}
</div>
{template 'common/footer'}
